const app=getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    userInfo: {
      type: Object,
      value: {},
      observer(newVal, oldVal, changedPath) {
        // console.info("userinfo", newVal);
      }
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    assistmode:0,
    sel_show:false,
  },
  attached (){
    this.setData({
      sel_show: (app.functions.getLocalStorage("assistmode") == 0) ? false:true
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getSubscribeMessage(){
      wx.openSetting({
        success(res) {
          // console.log(res.authSetting)
        }
      })
    },
    toAssistMode() {
      let that = this;
      let assist = app.functions.getLocalStorage('assistmode');
      if (app.functions.isEmpty(assist)) {
        wx.showModal({
          title: '提示', //提示的标题,
          content: '开启代客下单模式', //提示的内容,
          showCancel: true, //是否显示取消按钮,
          cancelText: '取消', //取消按钮的文字，默认为取消，最多 4 个字符,
          cancelColor: '#000000', //取消按钮的文字颜色,
          confirmText: '去购物', //确定按钮的文字，默认为取消，最多 4 个字符,
          confirmColor: '#3CC51F', //确定按钮的文字颜色,
          success: res => {
            app.functions.setLocalStorage('assistmode', 1);
            that.setData({
              sel_show:true,
              assistmode: 1
            })
            if (res.confirm) {
              wx.switchTab({
                url: '/pages/home/home'
              })
            }
          }
        });
      } else {
        app.functions.removeLocalStorage('assistmode');
        that.setData({
          assistmode: 0,
          sel_show:false
        },()=>{
          app.functions.showToast("取消代客下单");
        })
      }
    },
    //设置 
    toinformation() {
      wx.navigateTo({
        url: '/pages_user/information/information'
      })
    },
    // 注册团长
    goApply() {
      wx.navigateTo({
        url: "/pages_user/shop_reg/shop_reg"
      })
    },
    // 跳转到地址管理
    goAddressList(){
      wx.navigateTo({
        url:"/pages_user/address_list/address_list"
      })
    }
  }
  
})
